<?php

namespace App\Criteria\Home;

use Prettus\Repository\Contracts\CriteriaInterface;
use Prettus\Repository\Contracts\RepositoryInterface;

/**
 * Class HomeTemplateStencilByTemplateIdCriteria.
 *
 * @package namespace App\Criteria\Home;
 */
class HomeTemplateStencilByTemplateIdCriteria implements CriteriaInterface
{

    /**
     * @var int
     */
    protected $templateId = 0;

    /**
     * HomeTemplateStencilByTemplateIdCriteria constructor.
     * @param int $template
     */
    public function __construct(int $template)
    {
        $this->templateId = $template;
    }

    /**
     * Apply criteria in query repository
     *
     * @param string              $model
     * @param RepositoryInterface $repository
     *
     * @return mixed
     */
    public function apply($model, RepositoryInterface $repository)
    {
        return $model->where('template_id', $this->templateId);
    }
}
